package github.fafaovo.network;

import github.fafaovo.example;
import github.fafaovo.network.Packet.Power;
import github.fafaovo.network.Packet.PowerClinetForServer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;

public class NetworkRegistryHandler {
    public static SimpleChannel CHANNEL;
    private static final String VERSION = "0.1.0"; //多个包之间版本不能一样
    private static int ID = 0;
    //每次发包都需要更新ID
    public static int nextID(){return ID++;}
    public static void registerMessage()
    {
        CHANNEL = NetworkRegistry.newSimpleChannel(
                new ResourceLocation(example.MOD_ID,"orange"), //这个必须小写
                ()->VERSION, //对比版本
                (version)->version.equals(VERSION),
                (version)->version.equals(VERSION));

        CHANNEL.registerMessage(nextID(),
                Power.class,
                Power::encode,
                Power::decode,
                Power::handlePacket);

        CHANNEL.registerMessage(nextID(),
                PowerClinetForServer.class,
                PowerClinetForServer::encode,
                PowerClinetForServer::decode,
                PowerClinetForServer::handlePacket);





    }


}
